<%@taglib prefix = "c" uri = "http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix = "fmt" uri = "http://java.sun.com/jsp/jstl/fmt"%>
<%@taglib prefix = "fn" uri = "http://java.sun.com/jsp/jstl/functions"%>

<h2><fmt:message key = "form.requestList"/></h2>

<div class = "messages"><jsp:include page = "/messages.jsp"/></div>

<div id="box">
<table>
  <tr>  
    <td>
      <a class="simple" href="javascript:toggle_block('client_searchform');"  title="display&frasl;hide search form">
        <fmt:message key = "Command.search"/>
      </a>
    </td>
    <td valign="bottom">
      <a class="simple" href="javascript:toggle_block('client_searchform');" title="display&frasl;hide search form">
        <img src="/servicedeskClient/images/plus.gif" width="16" height="16"/>
      </a>
    </td>
  </tr>
</table>


<form action="clientui" method="post" name="searchform" id="client_searchform">
   <table class = "form">
      <tr>
         <td class = "label"><fmt:message key = "request.text"/></td>
         <td>
            <input name="text" value='<c:out value="${param['text']}"/>'>
         </td>
      </tr>
      <tr>
         <td class = "label"><fmt:message key = "request.status"/></td>
         <td>
            <select name="status">
              <c:forEach var = "status" items = "${statusList}">
                <option value="${status.id}" 
                  ${status.id == param["status"] ? "selected" : ""}>${status.status}
                </option>
              </c:forEach> 
            </select>
         </td>
      </tr>
      <tr>
         <td class = "label"><fmt:message key = "request.id"/></td>
         <td>
            <input name="id" value="<c:out value='${param["id"]}'/>">
         </td>
      </tr>
      <tr>
         <td class = "label"><fmt:message key = "request.regNumber"/></td>
         <td>
            <input name="regnumber" value='<c:out value="${param['regnumber']}"/>'>
         </td>
      </tr>
  </table>

<input type="hidden" name="_action" value="search">
[<a href = 'javascript:doAction("search");'><fmt:message key = "Command.search"/></a>]
</form>
</div>

<p>
<ul class="navbar2">
    <li><fmt:message key = "Command.sort"/></li>
    <li><a href="clientui?_action=${action}&orderBy=N&order=${order}&page=${currentPage}${searchAttributes}">N</a></li>            
    <li><a href="clientui?_action=${action}&orderBy=regnumber&order=${order}&page=${currentPage}${searchAttributes}"><fmt:message key = "request.regNumber"/></a></li>                
    <li><a href="clientui?_action=${action}&orderBy=status&order=${order}&page=${currentPage}${searchAttributes}"><fmt:message key = "request.status"/></a></li>
    <li><a href="clientui?_action=${action}&orderBy=registrationdate&order=${order}&page=${currentPage}${searchAttributes}"><fmt:message key = "request.regDate"/></a></li>    
</ul>           
</p>

<p><jsp:include page = "/pageNavigation.jsp"/></p>

<c:forEach var = "request" items = "${requestsList}">
<div class="listitem">
   <div class="backgroundcolor-${request.requestStatus.id}">
   <div class="listitemheader">
      <span class="key">N: </span><c:out value="${request.id}"/>; 
      <span class="key"><fmt:message key = "request.regNumber"/> </span><c:out value="${request.regNumber}"/>; 
      <span class="key"><fmt:message key = "request.status"/> </span><a href="clientui?_action=displayHistory&request_id=${request.id}" title="${request.requestStatus.comment}"><c:out value="${request.requestStatus.status}"/></a>;
      <span class="key"><fmt:message key = "request.regDate"/> </span><fmt:formatDate value="${request.registrationDate}" pattern="dd.MM.yyyy HH:mm"/>; 
      <span class="key"><fmt:message key = "request.approxEndDate"/> </span><fmt:formatDate value="${request.approxEndDate}" pattern="dd.MM.yyyy HH:mm"/>;
   </div>
   <div class="listitemcontent">
   <c:choose>
     <c:when test='${request.clientText == null}'>
       <c:out value="${request.dispatcherText}"/>
     </c:when>
     <c:otherwise>
       <c:out value="${request.clientText}"/>
     </c:otherwise>
   </c:choose>
   <span id="quote">&nbsp;</span>
   </div>
   <div class="listitemfooter"></div>
   </div>
</div>
</c:forEach>

<p><jsp:include page = "/pageNavigation.jsp"/></p>